package principle.singleResponsibility;

/*
    使用单一职责原则改进Demo01
 */
public class Demo02 {
    public static void main(String[] args) {
        Vehicle1 skyVehicle = new SkyVehicle();
        skyVehicle.run("飞机");
        Vehicle1 wayVehicle = new WayVehicle();
        wayVehicle.run("汽车");
        Vehicle1 waterVehicle = new WaterVehicle();
        waterVehicle.run("轮船");
    }
}
abstract class Vehicle1{
    public abstract void run(String name);
}
//天上的交通工具
class SkyVehicle extends Vehicle1{
    @Override
    public void run(String name) {
        System.out.println(name+"在空中运行...");
    }
}
//路上的交通工具
class WayVehicle extends Vehicle1{
    @Override
    public void run(String name) {
        System.out.println(name+"在路上运行...");
    }
}
//水上的交通工具
class WaterVehicle extends Vehicle1{
    @Override
    public void run(String name) {
        System.out.println(name+"在水上运行...");
    }
}
